package com.qq.supplier.mapper;

import com.qq.supplier.entity.Part;
import com.qq.supplier.entity.PartIn;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface PartMapper {

    //添加订单---进货页面
    @Insert("insert into part(id,part_var,part_name,part_version,part_color,part_address,part_source,part_indate,part_inprice,part_total,part_allprice) values(null,#{partVar},#{partName},#{partVersion},#{partColor},#{partAddress},#{partSource},#{partInDate},#{partInPrice},#{partTotal},#{partTotalPrice})")
    int addPart(Part part);

    //查找所有配件----展示进货页
    @Select("select * from part")
    List<Part> queryAll();

    //查找主页的数据---便于修改配件数量
    @Select("select * from part_in pi where pi.id=#{id}")
    PartIn queryOne(String id);

    //主页面修改配件数量----字段内容相同则累加
    @Update("update part_in pi set part_totals=#{partTotals} where pi.id=#{id}")
    int editPartIn(PartIn partIn);

    //查看---主页面
    @Select("select * from part_in")
    List<PartIn> finds();

    //添加数据到主页
    @Insert("insert into part_in(id,part_vars,part_names,part_versions,part_colors,part_addresss,part_sources,part_indates,part_inprices,part_totals) values(null,#{partVar},#{partName},#{partVersion},#{partColor},#{partAddress},#{partSource},#{partInDate},#{partInPrice},#{partTotal})")
    int addPartIn(Part part);

    //查找数据
    @Select("select * from part_in where part_vars=#{partVar} and part_names=#{partName} and part_versions=#{partVersion} and part_colors=#{partColor} and part_addresss=#{partAddress} and part_sources=#{partSource}")
    PartIn select(Part part);


   /* //详情页
    @Select("select * from order_part op where op.brands=#{brands} and op.types=#{types}")
    List<Order_part> selectPart(String brands,String types);
*/

}
